package com.xuelang.pipeline.client.pipeline.enums;

import lombok.Getter;

/**
 * @author liuyuan.ly
 * @since 2024/6/17 18:14
 */

@Getter
public enum RedLineInfoEnum {

    THU("bugs", "缺陷"),
    FRI("vulnerabilities", "漏洞"),
    SAT("code_smells", "坏味道");

    private final String key;
    private final String value;

    RedLineInfoEnum(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public static RedLineInfoEnum fromValue(String value) {
        for (RedLineInfoEnum redLineInfo : RedLineInfoEnum.values()) {
            if (redLineInfo.value.equals(value)) {
                return redLineInfo;
            }
        }
        throw new IllegalArgumentException("Invalid value: " + value);
    }

    public static RedLineInfoEnum fromKey(String key) {
        for (RedLineInfoEnum redLineInfo : RedLineInfoEnum.values()) {
            if (redLineInfo.key.equals(key)) {
                return redLineInfo;
            }
        }
        throw new IllegalArgumentException("Invalid value: " + key);
    }
}
